import { createDiscreteApi } from 'naive-ui';
const { message, dialog } = createDiscreteApi(['message', 'dialog', 'notification', 'loadingBar']);

let Tip = (type: keyof typeof dialog, content: any) => {
  return new Promise<{ message }>((resolve, reject) => {
    dialog[type]({
      title: '警告',
      content: content,
      positiveText: '确定',
      negativeText: '取消',
      onPositiveClick: () => {
        resolve({ message });
      },
      onNegativeClick: () => {
        reject({ message });
      }
    });
  });
};

const Success = (content: string) => Tip('success', content);
const Warning = (content: string) => Tip('warning', content);
const Error = (content: string) => Tip('error', content);
const Info = (content: string) => Tip('info', content);

export { Success, Warning, Error, Info };
